package com.qiyue.admin.entity.base;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.qiyue.orm.jpa.model.BaseEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import javax.persistence.*;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * Created by y747718944 on 2018/2/7
 */
@Entity
@Table(name="base_element")
@ApiModel("主键表")
public class Element  extends BaseEntity{

    @Column(name = "code" ,length = 16)
    private String code;
    @Column(name = "type" ,length = 16)
    private String type;
    @Column(name = "name" ,length = 16)
    private String name;
    @Column(name = "uri" ,length = 16)
    private String uri;

    private String title;
    @Column(name = "parent_id" ,length = 16)
    private String parentId;
    @Column(name = "path" ,length = 32)
    private String path;
    @Column(name = "method" ,length = 32)
    private String method;
    @Column(name = "description" ,length = 32)
    private String description;



    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getUri() {
        return uri;
    }

    public void setUri(String uri) {
        this.uri = uri;
    }



    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Transient
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }



    @ApiModelProperty(value = "主键关联resource_id关系,取消hibernate创建外键关系")
    private List<ResourceAuthority> resourceAuthority;

    @OneToMany(cascade=CascadeType.ALL, fetch = FetchType.LAZY, mappedBy="element")
    @JsonIgnore
    public List<ResourceAuthority> getResourceAuthority() {
        return resourceAuthority;
    }

    public void setResourceAuthority(List<ResourceAuthority> resourceAuthority) {
        this.resourceAuthority = resourceAuthority;
    }


    @ApiModelProperty(value = "menu的组件外键ID 多对一的关系")
    private Menu menu;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "menu_id")
    @JsonIgnore
    public Menu getMenu() {
        return menu;
    }

    public void setMenu(Menu menu) {
        this.menu = menu;
    }


}
